﻿using System;
using System.Data;


namespace DBEntitie.Extensions
{
  public static class SyBaseEntitiesExtensions
  {
    public static void AdoTran(this SyBaseEntities db, Action<SyBaseEntities> action)
    {
      try
      {
        db.Client.BeginTransaction(IsolationLevel.Serializable);
        action(db);
        db.Client.Transaction.Commit();
      }

      catch (Exception)
      {
        db.Client.Transaction.Rollback();
        throw;
      }
    }
  }
}
